<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        body{
            background: #000;
        }
        *{margin: 0;padding: 0;}
        ul{
            position: absolute;
        }
        ul li{
            width: 83px;
            height: 42px;
            list-style: none;
            float: left;
            text-align: center;
            line-height: 42px;
        }
        .nav{
            width: 800px;
            height: 42px;
            margin: 100px auto;
            background: url("./images/rss.png") right no-repeat #fff;
            border-radius: 5px;
            position: relative;
        }
        #cloud{
            width: 83px;
            height: 42px;
            background: url(./images/cloud.gif) no-repeat;
            position: absolute;
            left: 0;
            top:0;
        }
    </style>
    <script src="../js/animate.js"></script>
</head>
<body>
    <div class="nav">
        <span id="cloud"></span>
        <ul>
            <li>首页新闻</li>
            <li>师资力量</li>
            <li>活动策划</li>
            <li>企业文化</li>
            <li>招聘信息</li>
            <li>公司简介</li>
            <li>长沙校区</li>
            <li>深圳校区</li>
        </ul>
    </div>
    <script>
        class JdCloud{
            constructor(ele){
                this.el=document.querySelector(ele);
                this.oCloud=this.el.children[0];
                this.oLis=Array.prototype.slice.call(this.el.children[1].children);
                this.tempIndex=0;
                this.mouseHandler();
            }
            mouseHandler(){
                this.oLis.forEach((item,index) => {
                    item.onmouseenter=()=>{
                        utils.aniamte(this.oCloud,{left:index*83});
                    }
                    item.onclick=()=>{
                        this.tempIndex=index*83;
                    }
                });
                var self=this;
                this.el.onmouseleave=function(){
                    this.el.aniamte(self.oCloud,{left:self.tempIndex});
                }
            }
        }
        new JdCloud(".nav");
    </script>
</body>
</html>